FROM centos:latest

#修改时区
RUN /bin/cp /usr/share/zoneinfo/Asia/Shanghai /etc/localtime && echo "Asia/Shanghai" > /etc/timezone

#创建redis运行用户
RUN  groupadd -r redis \
     && useradd -r -g redis redis

#添加centos源
#RUN sed -i 's/dl-cdn.alpinelinux.org/mirrors.aliyun.com/g' /etc/yum.repos.d/*
COPY ./epel-7.repo /etc/yum.repos.d/epel.repo


#相关依赖文件
RUN   yum update -y \
      &&  yum -y clean all  \
      &&  yum -y makecache  \
      &&  yum -y install epel-release \
      &&  yum -y install  gcc gcc-c++ autoconf automake make zlib zlib-devel net-tools openssl* pcre* wget vim linux-headers \
      &&  yum clean all  && rm -rf /var/cache/yum/*

#创建redis安装目录
RUN mkdir -p /usr/src/redis \
    && mkdir -p /usr/src/redis/data \
    && mkdir -p /usr/src/redis/conf \
    && mkdir -p /usr/src/redis/log  \
    && mkdir -p /var/log/redis

#下载redis安装包
RUN wget "http://download.redis.io/releases/redis-4.0.11.tar.gz" -O /usr/src/redis-4.0.11.tar.gz \
    && tar -zxf /usr/src/redis-4.0.11.tar.gz -C /usr/src \
    && ln -s /usr/src/redis-4.0.11 /usr/local/redis \
    && rm -rf /usr/src/redis-4.0.11.tar.gz

#安装redis
RUN cd /usr/local/redis && make && make install

#工作目录
WORKDIR /usr/local/redis

#声明端口
#EXPOSE 6380

CMD ["/bin/bash"]